#include "stdafx.h"
#include "AddObjectTwBar.h"

#include "WorldData.h"
#include "NodeUtil.h"
#include "Light.h"

static TwBar * bar = NULL;

static mscene::WorldData worldData;

void TW_CALL addSphere(void *clientData)
{
	mscene::PrimitiveNodeDesc desc;
	mscene::createSphereNode(desc, worldData);
}

void TW_CALL addBox(void *clientData)
{
	mscene::PrimitiveNodeDesc desc;
	mscene::createBoxNode(desc, worldData);
}

void TW_CALL addPlane(void *clientData)
{
	mscene::PrimitiveNodeDesc desc;
	mscene::createPlaneNode(desc, worldData);
}

void TW_CALL addPointLight(void *clientData)
{
	mscene::PrimitiveNodeDesc desc;
	mgfx::PointLightDesc lightDesc;
	mscene::createPointLightNode(desc, lightDesc, worldData);
}

void TW_CALL addSpotLight(void *clientData)
{
	mscene::PrimitiveNodeDesc desc;
	mgfx::SpotLightDesc lightDesc;
	mscene::createSpotLightNode(desc, lightDesc, worldData);
}

void medit::showAddObjectBar(const mscene::WorldData & data)
{
	worldData = data;

	if(bar == NULL)
		bar = TwNewBar("Add object");
	TwSetTopBar(bar);

	TwRemoveAllVars(bar);

	TwAddButton(bar, "Sphere", addSphere, NULL, "");
	TwAddButton(bar, "Box", addBox, NULL, "");
	TwAddButton(bar, "Plane", addPlane, NULL, "");
	TwAddButton(bar, "Point light", addPointLight, NULL, "");
	TwAddButton(bar, "Spot light", addSpotLight, NULL, "");
}

void medit::hideAddObjectBar()
{
	if(bar != NULL)
		TwDeleteBar(bar);
	bar = NULL;
}